package com.hymanting.blog.resource;

import com.hymanting.blog.application.ArticleApplicationService;
import com.hymanting.blog.domain.article.Article;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author hxchen
 * @Date 2021/6/20
 */
@Path("/user")
@Component
//@CacheConfig(cacheNames = "resource.account")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class UserResource {

    /**
     * 根据文章Id获取文章详情
     */
    @POST
    @Path("/login")
//    @Cacheable(key = "#articleid")
    public Map getArticle(@RequestBody Map map) {
        Map resultMap = new HashMap();
        if(!"hyman".equals(map.get("username"))
        || !"123!@#".equals(map.get("password"))) {
            resultMap.put("code", -1);
            resultMap.put("message", "用户名或密码错误!");
            return resultMap;
        }

        Map dataMap = new HashMap();

        dataMap.put("token", "abcdefgasdadad");
        resultMap.put("data", dataMap);

        resultMap.put("code", 20000);
        return resultMap;
    }
}
